import request from '@/utils/request'

// 1. 上传 PDF 文件并保存历史记录
export function saveMaterialHistory(formData) {
    return request({
        url: '/material/history/save',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}

// 2. 根据 ID 查询材料历史记录
export function getMaterialHistoryById(id) {
    return request({
        url: `/material/history/get/${id}`,
        method: 'get'
    });
}

// 3. 分页查询材料历史记录
export function listMaterialHistory(page = 1, size = 10) {
    return request({
        url: '/material/history/list',
        method: 'get',
        params: { page, size }
    });
}

// 4. 删除材料历史记录
export function deleteMaterialHistory(id) {
    return request({
        url: `/material/history/delete/${id}`,
        method: 'delete'
    });
}

// 5. 更新材料历史记录中的文件名（title）
export function updateMaterialHistoryTitle(id, title) {
    return request({
        url: `/material/history/update/${id}`,
        method: 'put',
        params: { title }
    });
}


// 6. 获取 PDF 转换后的图片列表
export function getPdfImages(filePath) {
    return request({
        url: '/upload/pdfImages',
        method: 'get',
        params: { filePath }
    });
}

// 7. 合并图片为 PDF
export function mergeImagesToPdf(mergeData) {
    return request({
        url: '/file/merge/imagesToPdf',
        method: 'post',
        data: mergeData,
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
